package cn.edu.hust.youth.tzb.servlet.student;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import cn.edu.hust.youth.tzb.model.Student;
import cn.edu.hust.youth.tzb.service.StudentServiceException;
import cn.edu.hust.youth.tzb.service.StudentServiceImpl;
import cn.edu.hust.youth.tzb.service.UtilBean;




public class Modifystudentinfo extends HttpServlet {
	private static final String CONTENT_TYPE = "text/html; charset=GBK";
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		HttpSession session = request.getSession(true);
        response.setContentType(CONTENT_TYPE);
        PrintWriter out = response.getWriter();
        String personnum=request.getParameter("personnum");
        String name=request.getParameter("name");
        String sex=request.getParameter("sex");
        String birthday=request.getParameter("birthday");
        String nationality=request.getParameter("nationality");
        String jiguan=request.getParameter("jiguan");
        String lxdz=request.getParameter("lxdz");
        String dianhua=request.getParameter("dianhua");
        String youxiang=request.getParameter("youxiang");
        String academy=request.getParameter("academy");
        String department=request.getParameter("department");
        String grade=request.getParameter("grade");
        String studentclass=request.getParameter("studentclass");
        String erolltime=request.getParameter("erolltime");
        String mianmao=request.getParameter("mianmao");
        String studentid=request.getParameter("studentid");
        String uid=request.getParameter("uid");
        String xh=request.getParameter("xh");
        String teamid=request.getParameter("teamid");
        //System.out.println("modify:uid="+uid);
       // System.out.println(name+"---"+department+"----"+erolltime+"---"+mianmao);
       //System.out.println(studentid+"---"+personnum+"---"+sex+"--"+birthday+"---"+nationality+"---"+jiguan+"----"+academy+"---"+grade+"---"+studentclass);
        Student s=new Student();
        s.setName(name);
        s.setPersonnum(personnum);
        s.setSex(sex);
        s.setBirthday(birthday);
        s.setMinzu(nationality);
        s.setMianmao(mianmao);
        s.setJiguan(jiguan);
        s.setLxdz(lxdz);
        s.setDianhua(dianhua);
        s.setYouxiang(youxiang);
        s.setAcademy(academy);
        s.setDepartment(department);
        s.setGrade(grade);
        s.setSclass(studentclass);
        s.setErolltime(erolltime);
        s.setId(uid);
        s.setXh(xh);
        s.setTeamid(teamid);
        s.setModifytime(UtilBean.getCurrentTime(2));
        //session.setAttribute("STUDENT",s);
        StudentServiceImpl ssi=new StudentServiceImpl();
        //System.out.println(uid+"--uid-");

        out.println("<html>");
        out.println("<head><title>modifystudentinfo</title></head>");
        out.println("<link href='../../css/common.css' rel='stylesheet' type='text/css' media='all'>");

         out.println("<body background=\"../../images/bj_main.gif\">");
         try {
                     ssi.modifyInfo(uid,s);
                     String target = "/student/modifystudentinfo_success.jsp";
                     RequestDispatcher rd = this.getServletContext().getRequestDispatcher(target);
                     rd.forward(request,response);



                 } catch (Exception ex) {
                     String target = "/student/modifystudentinfo_failed.jsp";
                     RequestDispatcher rd = this.getServletContext().getRequestDispatcher(target);
                     rd.forward(request,response);


        }
        out.println("</body>");
        out.println("</html>");
        out.close();
	}

	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(req, resp);
	}

}
